package com.xbb.monitor.controller;

import com.xbb.monitor.entity.Cpu;
import com.xbb.monitor.entity.echarts.LineBean;
import com.xbb.monitor.repository.CpuRepository;
import com.xbb.monitor.service.CpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HelloController {
    @Autowired
    private CpuService cpuService;
    @Autowired
    private CpuRepository cpuRepository;

    @RequestMapping
    public List<LineBean> hello(){
//        cpuService.test();
//        return "hello";
//        List<LineBean> lineBeans = cpuService.daysData("oneHour");
        return null;
    }

    @Transactional
    @RequestMapping("aaa")
    public void test(){
        Cpu cpu1 = new Cpu();
        cpu1.setIdle(1.1f);
        cpuRepository.save(cpu1);

        Cpu cpu2 = new Cpu();
        cpu2.setIdle(2.1f);
        cpuRepository.save(cpu2);

        Cpu cpu3 = new Cpu();
        cpu3.setIowait(3.1f);
        cpuRepository.save(cpu3);


    }
}
